package service

import (
	"day12_12_homework/config"
	"math/rand/v2"
	"time"
)

func SendSms(tel string, source string) string {
	Loc := "sendSms_loc_" + source + tel
	Num := "sendSms_" + source + tel
	get := config.Rdb.Get(config.Ctx, Loc)
	if get.Val() != "" {
		return "请稍后再试"
	}
	i := rand.IntN(9000) + 1000
	/*resp, err := pkg.SendSms(tel, strconv.Itoa(i))
	if err != nil {
		return "短信发送失败"
	}
	if *resp.Body.Code != "OK" {
		return *resp.Body.Message
	}*/
	config.Rdb.Set(config.Ctx, Loc, "短信锁", time.Minute*5)
	config.Rdb.Set(config.Ctx, Num, i, time.Minute*2)
	return ""
}
